angularjs call js function

90

angularjs call js function -

<!--HTML-->
<div id="YourElementId" ng-app='MyModule' ng-controller="MyController">
    Hi
</div>

<script>
//JS Code
angular.module('MyModule', [])
    .controller('MyController', function ($scope) {
    $scope.myfunction = function (data) {
        alert("---" + data);
    };
});

window.onload = function () {
    angular.element(document.getElementById('YourElementId')).scope().myfunction('test');
}
</script>

Comments

Submit
0 Comments